Improve handling of subprocess shutdown on MS-Windows.
authorEli Zaretskii <eliz@gnu.org>
Sun, 23 Dec 2012 17:06:58 +0000 (19:06 +0200)
committerEli Zaretskii <eliz@gnu.org>
Sun, 23 Dec 2012 17:06:58 +0000 (19:06 +0200)
commit7f346b01f82cb45cffef37b1ff76afdd778fd612
tree80faea233f96168cf5dc16dd9ef69bb55f097e23
parentb8ccac267a53e04616f525f6e22cdc2330095476
Improve handling of subprocess shutdown on MS-Windows.

 src/w32proc.c (reader_thread): Do not index fd_info[] with negative
 values.
 (reader_thread): Exit when cp->status becomes STATUS_READ_ERROR
 after WaitForSingleObject returns normally.  This expedites reader
 thread shutdown when delete_child triggers it.
 (reap_subprocess): More accurate commentary for why we call
 delete_child only when cp->fd is negative.
 src/w32.c (sys_close): Do not call delete_child on a subprocess
 whose handle is not yet closed.  Instead, set its file descriptor
 to a negative value, so that reap_subprocess will call
 delete_child on that subprocess when its SIGCHLD arrives.  This
 avoids closing handles used for communications between sys_select
 and reader_thread, which doesn't give sys_select a chance to
 notice that the process exited and invoke the SIGCHLD handler for
 it.
src/ChangeLog
src/w32.c
src/w32proc.c